﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="qst_manage_index.aspx.cs" Inherits="Ccit.OA.Question.qst_manage_index" %>
<%@ Register assembly="DevExpress.Web.ASPxGridView.v8.1" namespace="DevExpress.Web.ASPxGridView" tagprefix="dxwgv" %>
<%@ Register assembly="DevExpress.Web.ASPxEditors.v8.1" namespace="DevExpress.Web.ASPxEditors" tagprefix="dxe" %>
<%@ Register TagPrefix="ccit" Namespace="Ccit.ServerControls" Assembly="Ccit.ServerControls.ActionForm" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>调查问卷-问卷管理</title>
    <script language="javascript" type="text/javascript" src="../script/jquery.js"></script>
    <script language="javascript" type="text/javascript" src="../script/StringClass_Ext.js"></script>
    <script language="javascript" type="text/javascript" src="../script/jsonlib.js"></script>
    <script language="javascript" src="../script/jwindow.js"></script>
    <script language="javascript" src="../script/jbase64.js" type="text/javascript"></script>
    <script type="text/javascript">
        //新增
        function doAdd()
        {
              var TabId = $get("_hidTabId").value;
              var oPageParam="TABID="+TabId;  
              var oEncodeParam=base64encode(oPageParam);
              var strUrl = "qst_manage_edit.aspx?"+oEncodeParam;
              window.location.href = strUrl;
        }
        function doCtrlv(vSId)
        {
            PageMethods.DoCopy(vSId,ClientCallBack);    
        }
        function doEdit(vSId)
        { 
             var TabId = $get("_hidTabId").value;
             var oPageParam="Id="+vSId+"&TABID="+TabId;
             var oEncodeParam=base64encode(oPageParam);
             var strUrl="qst_manage_edit.aspx?"+oEncodeParam;
             window.location.href = strUrl;
        }
        function doView(vSId)
        { 
             var oPageParam="Id="+vSId;
             var oEncodeParam=base64encode(oPageParam);
             var strUrl="qst_manage_View.aspx?"+oEncodeParam;
             OpenWindow(strUrl,"","800","600")
        }
        function doUpdate()
        {
            var typeId ="0";
            var vId = document.getElementById("_hidTypeID").value;
            //alert(vId);
            var msQuestion = {};
		    if(vId!="")
		        {
		            if(confirm("修改当前记录,是否继续?")) 
		            {
		               msQuestion.id = vId;
		               msQuestion.state = $get("ddlStaues").value;
		               if(msQuestion.state=="0")
		               {
                           if(confirm("将清除所选问卷的已有答案,是否继续?")) 
		                   {
		                         var jsonExpr = JSON.stringify(msQuestion,function(key,value){return value;}); 
		                          msQuestion = null;
                                  PageMethods.DoOperate(jsonExpr,typeId,ClientCallBack);   
		                   }	        
		               }
		               else
		               {
		                   var jsonExpr = JSON.stringify(msQuestion,function(key,value){return value;}); 
		                   msQuestion = null;
                           PageMethods.DoOperate(jsonExpr,typeId,ClientCallBack);    
                       }
                   }
                }
                else
                {
                    alert("尚未有您要修改的数据");
                }  
        }
        //删除
		function doDel(vId)
		{ 
		    var typeId ="1";
		    if(vId=="0")
		    {
		        vId = document.getElementById("_hidTypeID").value;
		    }
		    if(vId!="0")
		        {
		            if(confirm("删除当前记录,是否继续?")) 
                             PageMethods.DoOperate(vId,typeId,ClientCallBack);    
                }
                else
                {
                    alert("尚未有您要删除的数据");
                } 
		} 
		function ClientCallBack(vResult)
		{ 
		    eval("ObjResult =" +vResult);
		    if(ObjResult.resulttype!="-999")
		    {
		        __doPostBack("lnbQuery","");
		        alert(ObjResult.message); 
		        return true;
		    }
		    else
		    {
		        alert(ObjResult.message); 
		        return false;
		    }    		
		}
        //复选框选择
         var objState ; 
        function doDataGridItemSel( obj )
        {
          if ( objState != null )
          {
             objState.style.color = "";
             objState.style.backgroundColor = "";
          } 
          obj.style.color = "#fffeee";
          obj.style.backgroundColor = "#a0a0a0";        
          objState = obj;		                       
        }	
        function OnGridSelectionChanged(){           
            dgMain.GetSelectedFieldValues("id",OnGridSelectionComplete);
        }
        
        function OnGridSelectionComplete(values){
            document.getElementById("_hidTypeID").value=values;            
        }
        function doSelectInfo(vSId)
        {              
                var oPageParam="QId="+vSId;
                var oEncodeParam=base64encode(oPageParam);
                var strURL = "qst_manage_log.aspx?"+oEncodeParam;
                OpenWindow(strURL,"","1000","500")
        }
        function doCount(sRecId)
        {
             var oPageParam="Id="+sRecId;
             var oEncodeParam=base64encode(oPageParam);
             var strUrl="qst_statistics_view.aspx?"+oEncodeParam;
             OpenWindow(strUrl,"","800","600")
        }
    </script>
</head>
<body>
    <ccit:ActionForm id="form1" runat="server">
     <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
    </asp:ScriptManager> 
    <input type="hidden" id="_hidTypeID" runat="server" />
    <input type="hidden" id="_hidTabId" runat ="server" />
    <input type="hidden" id="_hidWhereClause" runat="server" />
   <table class="tbToolbar" cellpadding="0" cellspacing="0" width="98%" align="center">
                    <tr>
                        <td align="left">
                            <div class="tbSeparator"></div>
                        </td>
                        <td width="100%" class="titlebar">  
                            调查问卷-问卷管理
                        </td>                
                        <td align="right">
                            <nobr>
                                标题:                                  
                                <asp:TextBox ID="txttName" CssClass="input" Width="100" runat="server"></asp:TextBox>                    
                                &nbsp;状态:<asp:DropDownList ID="ddlStaue" CssClass="inputselect" Width="100" runat="server">
                                <asp:ListItem Value="4">全部</asp:ListItem>
                                <asp:ListItem Value="0">未发布</asp:ListItem>
                                <asp:ListItem Value="1">已发布</asp:ListItem>
                                <asp:ListItem Value="2">已结束</asp:ListItem>
                            </asp:DropDownList> 
                                &nbsp;<asp:LinkButton ID="lnbQuery" CssClass="linktext" runat="server" 
                                onclick="lnbQuery_Click" >
                                    <img src="../images/toolbar/search.gif" />查询
                                </asp:LinkButton> 
                                 <a  id="A1" Runat="server" class="linktext"  
                                href="javascript:doUpdate()">
                                    <img src="../images/toolbar/Displace.gif" />置为
                                 </a>
                                 <asp:DropDownList ID="ddlStaues" runat="server" CssClass="inputselect" Width="80">
                                     <asp:ListItem Value="0">未发布</asp:ListItem>
                                     <asp:ListItem Value="1">已发布</asp:ListItem>
                                     <asp:ListItem Value="2">已结束</asp:ListItem>
                            </asp:DropDownList>
                                <a  id="lnbAdd" Runat="server" class="linktext"  
                                href="javascript:doAdd()">
							        <img src="../images/toolbar/new.gif" border="0">新增
						        </a>
						         <a  id="lnbDel" Runat="server" class="linktext"  
                                href="javascript:doDel('0')">
							        <img src="../images/toolbar/Delete.gif" border="0">删除
						        </a>
                             </nobr>
                        </td> 
                    </tr>
       </table>
        <table cellpadding="0" cellspacing="0" width="98%" align="center">
                                <tr>
                                    <td colspan="3" width="100%">
                                      <dxwgv:ASPxGridView ID="dgMain" runat="server"
                                AutoGenerateColumns="False" Width="100%" KeyFieldName="id" 
                                            onhtmlrowcreated="dgMain_HtmlRowCreated">
                                            <SettingsPager AlwaysShowPager="True" PageSize="15">
                                                <FirstPageButton Visible="True">
                                                </FirstPageButton>
                                                <LastPageButton Visible="True">
                                                </LastPageButton>
                                            </SettingsPager>
                                             <Styles>
                                                <Row CssClass=""></Row>
                                                <AlternatingRow  CssClass="" Enabled="true"/>
                                                <SelectedRow  CssClass=""></SelectedRow>                
                                            </Styles>  
                                            <Columns>
                                                 <dxwgv:GridViewCommandColumn ShowSelectCheckbox="True" VisibleIndex="0" Width="2%">
                                                    <HeaderTemplate>
                                                        <input type="checkbox" id="chbCheck" runat="server" onclick="dgMain.SelectAllRowsOnPage(this.checked);"
                                                            style="vertical-align: middle;" title="Select/Unselect all rows on the page"></input>
                                                    </HeaderTemplate>
                                                    <HeaderStyle Paddings-PaddingTop="1" Paddings-PaddingBottom="1" HorizontalAlign="Center">
                                                        <Paddings PaddingTop="1px" PaddingBottom="1px"></Paddings>
                                                    </HeaderStyle>
                                                </dxwgv:GridViewCommandColumn>
                                                <dxwgv:GridViewDataTextColumn Caption="问卷标题" VisibleIndex="1" width="22%" FieldName="title">
                                                 <HeaderStyle HorizontalAlign="Center" />
                                                 <CellStyle HorizontalAlign="left"></CellStyle>
                                                </dxwgv:GridViewDataTextColumn>
                                                <dxwgv:GridViewDataTextColumn Caption="状态" VisibleIndex="2" width="8%" FieldName="state">
                                                  <HeaderStyle HorizontalAlign="Center" />
                                                  <CellStyle HorizontalAlign="Center"></CellStyle>
                                                </dxwgv:GridViewDataTextColumn>
                                                 <dxwgv:GridViewDataTextColumn Caption="类型" VisibleIndex="3" width="5%" FieldName="type">
                                                  <HeaderStyle HorizontalAlign="Center" />
                                                  <CellStyle HorizontalAlign="Center"></CellStyle>
                                                </dxwgv:GridViewDataTextColumn> 
                                                
                                                 <dxwgv:GridViewDataTextColumn Caption="已答复" VisibleIndex="4" width="8%" FieldName="ucount">
                                                  <HeaderStyle HorizontalAlign="Center" />
                                                  <CellStyle HorizontalAlign="Center"></CellStyle>
                                                </dxwgv:GridViewDataTextColumn>
                                                 <dxwgv:GridViewDataTextColumn Caption="发布时间" VisibleIndex="5" width="12%" FieldName="begintime">
                                                  <HeaderStyle HorizontalAlign="Center" />
                                                  <CellStyle HorizontalAlign="Center"></CellStyle>
                                                </dxwgv:GridViewDataTextColumn>
                                                 <dxwgv:GridViewDataTextColumn Caption="截止时间" VisibleIndex="6" width="12%" FieldName="endtime">
                                                  <HeaderStyle HorizontalAlign="Center" />
                                                  <CellStyle HorizontalAlign="Center"></CellStyle>
                                                </dxwgv:GridViewDataTextColumn>
                                                 <dxwgv:GridViewDataTextColumn Caption="结果统计" VisibleIndex="7" width="8%" FieldName="typename">
                                                  <HeaderStyle HorizontalAlign="Center" />
                                                  <CellStyle HorizontalAlign="Center"></CellStyle>
                                                </dxwgv:GridViewDataTextColumn>
                                                 <dxwgv:GridViewDataTextColumn Caption="操作" VisibleIndex="8" width="12%">
                                                  <HeaderStyle HorizontalAlign="Center" />
                                                  <CellStyle HorizontalAlign="Center"></CellStyle>
                                                   <DataItemTemplate>
                                                   <nobr>
                                                        <a id="lnbCtrlc" runat="server">复制</a>  
                                                        <a id="lnbEdit" runat="server">编辑</a>  
                                                        <a id="lnbDel" runat="server">删除</a>  
                                                        </nobr>
                                                   </DataItemTemplate>
                                                </dxwgv:GridViewDataTextColumn>
                                            </Columns>
                                             <%-- 复选框选择脚本事件 --%>
                                                    <ClientSideEvents SelectionChanged="function(s,e){OnGridSelectionChanged();}" />
                                        </dxwgv:ASPxGridView>
                                    </td>
                                </tr>
                            </table>
                        
    </ccit:ActionForm>
</body>
</html>
